package com.project.personalfundmanager.client.taxitems;

import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.project.personalfundmanager.client.common.Const;
import com.project.personalfundmanager.shared.models.SectionOthersModel;

public class SectionOthersItem extends ParentItem<SectionOthersModel>
{
	public SectionOthersItem( SectionOthersModel model )
	{
		super( model );
	}

	@Override
	public void addFormComponents( FormPanel formPanel, boolean isEditable )
	{
		addToPanel( formPanel, uiHelper.getNumberField( "Infrastructure Bonds(80CCF)", Const.INFRA_BONDS, isEditable, 20000 ) );
		addToPanel( formPanel, uiHelper.getNumberField( "Medical Insurance(80D)", Const.MEDICAL_INSURANCE, isEditable, 35000 ) );
		addToPanel( formPanel, uiHelper.getNumberField( "Medical Treatment / Insurance of handicapped Dependencies(80DD)", Const.MEDICAL_80DD, isEditable, 50000 ) );
		addToPanel( formPanel, uiHelper.getNumberField( "Medical Treatment for Specified Disease(80DDB)", Const.MEDICAL_80DDB, isEditable, 40000 ) );
		addToPanel( formPanel, uiHelper.getNumberField( "Repayment of Loan of higher Self education(80E)", Const.HIGHER_STUDY, isEditable, 999999 ) );
		addToPanel( formPanel, uiHelper.getNumberField( "Cheritable Donations(80G)", Const.DONATION, isEditable ) );
		addToPanel( formPanel, uiHelper.getNumberField( "Medical Treatement for Self Physical Disablity(80U)", Const.PHYSICAL, isEditable, 75000 ) );
		addToPanel( formPanel, uiHelper.getNumberField( "Income by Royalty like patent(80RRB)", Const.ROYALITY, isEditable ) );
	}

	@Override
	public void addTotalComponents( FormPanel totalPanel )
	{
		addToPanel( totalPanel, uiHelper.getNumberField( "Total", Const.SEC_OTHER_TOTAL, false ) );
	}

	@Override
	public void calculateTotal()
	{
		int total = model.getInfraBonds() + model.getMedicalInsurance() + model.getMedical80DD() + model.getMedical80DDB() + model.getHigherStudy() + model.getDonation() + model.getPhysical() + model.getRoyalty();
		model.setTotal( total );
	}
}
